package com.lagou.edu.util;


import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum CodeType {

    RIGHT(0, "正确"),
    WRONG(1, "验证码有误，请重新输入"),
    TIME_OUT(2, "验证码已过期，请重新获取"),
    OTHER(-1, "邮箱未验证，请获取验证码");

    private int code;
    private String desc;


    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 获取状态详细信息
     * @param code
     * @return
     */
    public static String getDesc(Integer code) {
        for (CodeType apiCodeEnum : CodeType.values()) {
            if (code.equals(apiCodeEnum.getCode())) {
                return apiCodeEnum.getDesc();
            }
        }
        return OTHER.getDesc();
    }
}
